home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.src.lzh / relay / hdrcommon.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  2KB  |  75 lines

  1. /*
  2.  * Usenet header common code.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #ifndef AMIGA
  7. #  include <sys/types.h>
  8. #endif /* AMIGA */
  9. #include "libc.h"
  10. #include "news.h"
  11. #include "headers.h"
  12. #include "hdrint.h"
  13.  
  14. void
  15. hdrdebug(state)
  16. int state;
  17. {
  18.     headdebug = state;
  19. }
  20.  
  21. void
  22. hdrinit(hdrs)            /* zero all elements of hdrs */
  23. register struct headers *hdrs;
  24. {
  25.     hdrs->h_subj = NULL;
  26.     hdrs->h_ngs = NULL;
  27.     hdrs->h_distr = NULL;
  28.     hdrs->h_ctlcmd = NULL;
  29.     hdrs->h_approved = NULL;
  30.     hdrs->h_msgid = NULL;
  31.     hdrs->h_artid = NULL;
  32.     hdrs->h_expiry = NULL;
  33.     hdrs->h_path = NULL;
  34.     hdrs->h_sender = NULL;
  35. }
  36.  
  37. boolean
  38. oldctl(hdrs)            /* true iff ngs are OLDCNTRL (cache in hdrs) */
  39. register struct headers *hdrs;
  40. {
  41. #ifdef SLOWCTLMATCH
  42.     return ngmatch(OLDCNTRL, hdrs->h_ngs);
  43. #else
  44.     register int ngslen = strlen(hdrs->h_ngs);
  45.  
  46.     if (ngslen < STRLEN(SFXOLDCNTRL))    /* ngs too short */
  47.         return NO;
  48.     else                    /* check for .ctl suffix */
  49.         /*
  50.          * This is more general than RFC 850 specifies, but this
  51.          * generality seems harmless.  This doesn't work for e.g.
  52.          * x.y.ctl,z.q, which is a darn shame, but that's a violation
  53.          * of common sense.
  54.          */
  55.         return STREQ(&hdrs->h_ngs[ngslen-STRLEN(SFXOLDCNTRL)],
  56.             SFXOLDCNTRL);
  57. #endif                        /* SLOWCTLMATCH */
  58. }
  59.  
  60. void
  61. freeheaders(hdrs)        /* free (assumed) malloced storage */
  62. register struct headers *hdrs;
  63. {
  64.     nnfree(&hdrs->h_subj);
  65.     nnfree(&hdrs->h_ngs);
  66.     nnfree(&hdrs->h_distr);
  67.     nnfree(&hdrs->h_ctlcmd);
  68.     nnfree(&hdrs->h_approved);
  69.     nnfree(&hdrs->h_msgid);
  70.     nnfree(&hdrs->h_artid);
  71.     nnfree(&hdrs->h_expiry);
  72.     nnfree(&hdrs->h_path);
  73.     nnfree(&hdrs->h_sender);
  74. }
  75.